package cn.zxy.mapper;

import cn.zxy.model.Student;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface StudentMapper {

    //根据id查询学生信息
    @Select("select * from student where cid=#{cid}")
    public List<Student> findByCid(Integer id);


    @Select("select distinct s.* from student s,stu_cr sc where sc.sid=s.id")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "name",property = "name"),
            @Result(column = "age",property = "age"),
            @Result(
                    column = "id",
                    property = "courses",
                    javaType = List.class,
                    many = @Many(select = "cn.zxy.mapper.CourseMapper.findBySid")
            )
    })
    public List<Student> findAll();




}
